<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>面向对象</title>
  </head>
  <body>
    <script>
      //ES5
      //People 是类名
      //   function People() {
      //     this.age = "";
      //     this.sex = "";
      //     this.say = function () {};
      //   }
      //   People.prototype.running = function () {};
      //   //zhangsan  是对象
      //   var zhangsan = new People();
      //   var lisi = new People();

      //ES6
      //   class People {
      //     constructor() {
      //       this.age = "";
      //       this.sex = "";
      //     }
      //     say() {}
      //   }
      //   let zhangsan = new People();

      //   function name(params) {}

      // 狗吃屎
      //面向过程  ---- > 吃
      //   var name = "";
      //   var age = "";
      //   function eat(params) {
      //     console.log("吃XXXX!" + params);
      //   }
      //   eat("XXXXX");
      //   eat("猪肉");

      //面向对象  ---- >  狗
      //   class Dog {
      //     constructor(name, age, color) {
      //       this.name = name;
      //       this.age = age;
      //       this.color = color;
      //     }
      //     eat(food) {
      //       console.log(
      //         this.name +
      //           "是一条大" +
      //           this.color +
      //           "狗，今年" +
      //           this.age +
      //           "岁,正在吃" +
      //           food
      //       );
      //     }
      //   }
      //   let tom = new Dog("tom", "2", "黄");
      //   let xiaohei = new Dog("xiaohei", "3", "黑");
      //   tom.eat("牛排");
      //   tom.eat("骨头");

      //
      //父类
      class people {
        constructor(name, age, sex) {
          this.name = name;
          this.age = age;
          this.sex = sex;
        }
        say(words) {
          console.log(words);
        }
      }
      //子类 子类继承父类 ， 父类的功能 子类可以继承 
      class child extends people {
        constructor(name, age, sex) {
          super(name, age, sex);
        }
        say(){
            console.log("我会说中文");
        }
        fly() {
          console.log("俺会飞！");
        }
      }
      class child1 extends people {
        constructor(name, age, sex) {
          super(name, age, sex);
        }
        say(){
            console.log("我会说英文");
        }
        fly() {
          console.log("俺会飞！");
        }
      }


      let maomao = new child();
      maomao.say("都是石头里面蹦出来的，为啥他是猴子！");
      maomao.fly();
      
    </script>
  </body>
</html>
